package com.b2.controller.web;

import com.b2.pojo.entity.CourseDimension;
import com.b2.result.Result;
import com.b2.service.CourseDimensionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/web/CourseDimension")
@Api(tags = "课程维度相关接口")
@Slf4j
@CrossOrigin
public class CourseDimensionController {

    @Resource
    private CourseDimensionService courseDimensionService;

    @GetMapping("/list")
    @ApiOperation("获取所有课程维度")
    public Result<List<CourseDimension>> list() {
        List<CourseDimension> list = courseDimensionService.list();
        return Result.success(list);
    }

    @PostMapping("/add")
    @ApiOperation("添加课程维度")
    public Result<List<String>> add(@RequestBody CourseDimension courseDimension) {
        courseDimensionService.add(courseDimension);
        return Result.success();
    }

    @DeleteMapping("/delete")
    @ApiOperation("删除课程维度")
    public Result<List<String>>  delete(@ApiParam("课程维度id") @RequestParam("dimensionId") Long dimensionId) {
        courseDimensionService.delete(dimensionId);
        return Result.success();
    }

    @PostMapping("update")
    @ApiOperation("修改课程维度")
    public Result<List<String>> update(@RequestBody CourseDimension courseDimension) {
        courseDimensionService.update(courseDimension);
        return Result.success();
    }
}
